"""Game configuration constants and helpers.

This module contains configurations for the game, including player, world, enemy, 
and time settings. It uses Python's dataclasses to create immutable objects with 
default values representing different aspects of the game.
"""

from dataclasses import dataclass


@dataclass(frozen=True)
class PlayerConfig:
    """玩家角色的配置设置。

    属性:
        width (int): 玩家角色的宽度。
        height (int): 玩家角色的高度。
        speed (int): 玩家每帧移动速度（以像素为单位）。
        jump_velocity (int): 跳跃时的初始速度。
        gravity (int): 玩家受到的重力效果。
        max_health (int): 玩家可拥有的最大生命值。
        max_stamina (int): 玩家可拥有的最大体力值。
        stamina_jump_cost (int): 执行跳跃所需的体力消耗。
        stamina_recovery_rate (int): 每帧体力恢复的速度。
    """
    """Configuration settings for the player character.

    Attributes:
        width (int): Width of the player character.
        height (int): Height of the player character.
        speed (int): Movement speed of the player in pixels per frame.
        jump_velocity (int): Initial velocity when jumping.
        gravity (int): Gravity effect on the player.
        max_health (int): Maximum health points the player can have.
        max_stamina (int): Maximum stamina points the player can have.
        stamina_jump_cost (int): Stamina cost for performing a jump.
        stamina_recovery_rate (int): Rate at which stamina recovers per frame.
    """
    width: int = 40
    height: int = 60
    speed: int = 8
    jump_velocity: int = 18
    gravity: int = 1
    max_health: int = 5
    max_stamina: int = 100
    stamina_jump_cost: int = 20
    stamina_recovery_rate: int = 1


@dataclass(frozen=True)
class WorldConfig:
    """游戏世界的配置设置。

    属性:
        block_size (int): 游戏世界中每个区块的大小。
        ground_offset (int): 从屏幕底部到地面水平线的偏移量。
        world_seed (int | None): 用于生成世界的种子。如果为 None，则使用随机种子。
        columns (int): 生成的世界列数。
        tree_count (int): 在世界中生成的树的数量。
        ore_spawn_chance (float): 在给定区块中生成矿石的概率。
    """
    """Configuration settings for the game world.

    Attributes:
        block_size (int): Size of each block in the game world.
        ground_offset (int): Offset from the bottom of the screen to the ground level.
        world_seed (int | None): Seed used for generating the world. If None, a random seed is used.
        columns (int): Number of columns in the generated world.
        tree_count (int): Number of trees to generate in the world.
        ore_spawn_chance (float): Probability of an ore spawning in a given block.
    """
    block_size: int = 40
    ground_offset: int = 100
    world_seed: int | None = None
    columns: int = 120
    tree_count: int = 12
    ore_spawn_chance: float = 0.35


@dataclass(frozen=True)
class EnemyConfig:
    """敌人的配置设置。

    属性:
        width (int): 敌人角色的宽度。
        height (int): 敌人角色的高度。
        base_speed (float): 敌人的基础移动速度。
        night_speed_multiplier (float): 夜晚时敌人速度的倍率。
        day_speed_multiplier (float): 白天时敌人速度的倍率。
    """
    """Configuration settings for enemies.

    Attributes:
        width (int): Width of the enemy characters.
        height (int): Height of the enemy characters.
        base_speed (float): Base movement speed of enemies.
        night_speed_multiplier (float): Multiplier applied to enemy speed during night time.
        day_speed_multiplier (float): Multiplier applied to enemy speed during day time.
    """
    width: int = 40
    height: int = 60
    base_speed: float = 2.0
    night_speed_multiplier: float = 1.6
    day_speed_multiplier: float = 0.7


@dataclass(frozen=True)
class TimeConfig:
    """游戏时间系统的配置设置。

    属性:
        day_length_seconds (int): 一个完整白天周期的持续时间（以秒为单位）。
        dusk_length_seconds (int): 黄昏的持续时间（以秒为单位）。
        night_length_seconds (int): 夜晚的持续时间（以秒为单位）。
    """
    """Configuration settings for the game's time system.

    Attributes:
        day_length_seconds (int): Duration of a full day cycle in seconds.
        dusk_length_seconds (int): Duration of dusk in seconds.
        night_length_seconds (int): Duration of night in seconds.
    """
    day_length_seconds: int = 120
    dusk_length_seconds: int = 20
    night_length_seconds: int = 60


# Frames per second at which the game runs.
# 游戏运行的每秒帧数。
FPS: int = 60

# Colors used for different types of blocks in the game.
# 游戏中不同类型方块的颜色。
BLOCK_COLORS = {
    "grass": (34, 139, 34),
    "dirt": (139, 69, 19),
    "stone": (128, 128, 128),
    "cloud": (255, 255, 255),
    "tree": (101, 67, 33),
    "ore": (70, 130, 180),
    "plank": (210, 180, 140),
    "stone_brick": (169, 169, 169),
}


# Colors used for different types of items in the game.
# 游戏中不同物品类型的颜色。
ITEM_COLORS = {
    "wood": (160, 82, 45),
    "stone": (128, 128, 128),
    "plank": (210, 180, 140),
    "ore_gem": (0, 191, 255),
    "stone_brick": (192, 192, 192),
}


# Background colors for different times of day.
# 不同时间段的背景颜色。
BACKGROUND_COLORS = {
    "day": (135, 206, 235),
    "dusk": (250, 128, 114),
    "night": (25, 25, 112),
}


# Colors used for the Heads-Up Display (HUD) elements.
# Heads-Up Display (HUD) 元素的颜色。
HUD_COLORS = {
    "panel": (50, 50, 50),
    "text": (255, 255, 255),
    "health": (220, 20, 60),
    "stamina": (72, 209, 204),
}


PLAYER_CONFIG = PlayerConfig()
WORLD_CONFIG = WorldConfig()
ENEMY_CONFIG = EnemyConfig()
TIME_CONFIG = TimeConfig()
